﻿Public Class frmPaciente

    Private nomPaciente As String
    Private codPaciente As Integer
    Private fechaN As Date
    Dim bd As New BTTbdDataContext
    Private Sub frmPaciente_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim paciente = From pac In bd.Pacientes _
                       Select pac

        Me.PacienteBindingSource.DataSource = paciente

    End Sub


    Private Sub btnSeleccionar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeleccionar.Click

        Me.codPaciente = dgvPaciente.CurrentRow.Cells("idPaciente").Value
        Me.nomPaciente = dgvPaciente.CurrentRow.Cells("nombre").Value
        Me.nomPaciente = nomPaciente + " " + dgvPaciente.CurrentRow.Cells("apePat").Value
        Me.nomPaciente = nomPaciente + " " + dgvPaciente.CurrentRow.Cells("apeMat").Value
        Me.fechaN = dgvPaciente.CurrentRow.Cells("fecNacimiento").Value

        Me.Close()

    End Sub

    Private Sub PacienteBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PacienteBindingNavigatorSaveItem.Click
        Try
            bd.SubmitChanges()
            MsgBox("Guardado")
        Catch ex As Exception
            MsgBox(ex.ToString)

        End Try

    End Sub

    Property _codPaciente() As Integer
        Get
            Return Me.codPaciente

        End Get
        Set(ByVal value As Integer)

            Me.codPaciente = value

        End Set
    End Property

    Property _nomPaciente() As String
        Get
            Return Me.nomPaciente
        End Get
        Set(ByVal value As String)

            Me.nomPaciente = value
        End Set
    End Property

    Property _fechaN() As Date
        Get
            Return Me.fechaN
        End Get
        Set(ByVal value As Date)
            Me.fechaN = value
        End Set
    End Property
   
End Class